--解锁屏幕
function RxIsApp(atable)
  local ctn = {status = 0, bid = ""}
  for i, v in pairs(atable) do
    -- RxLog(tostring(i)..":"..tostring(v)) -- 测试
    local appPath = appBundlePath(v)
    -- RxLog(tostring(i)..":".." appPath="..tostring(appPath)) -- 测试
    -- RxLog('appPath -> type='..type(appPath)..'===="'..appPath..'"==') -- 测试
    if type(appPath) == 'string' and appPath ~= "" then
      ctn.status = 1
      ctn.bid = v
      break
    elseif type(appPath) == 'nil' and appPath then
      ctn.status = 1
      ctn.bid = v
      break
    end
  end
  return ctn
end

function RxIsAppRun(bid)
  local ctn = 0
  if bid ~= "" then
    ctn = isFrontApp(bid)
  end
  return ctn
end

local function starGame()
  local gameCheck = isFrontApp(sysInit.gamebid)
  if gameCheck ~= 1 then
    local game = runApp(sysInit.gamebid)
    if game == 0 then -- 启动游戏
      mSleep(5000)
      return true
    end
  else --游戏已经启动了
    return true
  end
  return false
end

-- 根据ids启动app
function RxRunApp()
  local ctn = RxIsApp(GameBids)
  sysInit.gamebid = ctn.bid

  if ctn.status == 0 then
    return false
  else
    return starGame()
  end
end
